﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2
{
    class Class1
    {
        public static readonly string link = "server=.;database=chou;uid=sa;pwd=123456a";

        public static DataTable Query(string sql)
        {
            SqlConnection connection = new SqlConnection(link);
            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
            DataTable dt = new DataTable();
            connection.Open();
            adapter.Fill(dt);
            return dt;
        }

        public static DataTable up()
        {
            string sql = "select * from Userinfo";
            return Class1.Query(sql);
        }

        public static void adds(string a, string b, string c)
        {
            string sql = $"insert into Userinfo (StuName,StuSex,StyAdd) values ('{a}','{b}','{c}')";
            Class1.Query(sql);
        }
        public static void upds(string a,string b,string c,int i)
        {
            string sql = $"update Userinfo set StuName='{a}',StuSex='{b}',StyAdd='{c}' where StuID='{i}'";
            Class1.Query(sql);
        }
    }
}
